<template>
  <div class="tabs_view_table">
    <div class="tabs_view_header">
      <div class="tabs_view_table_left">
        <div
          v-for="header in headerList"
          :key="header.title"
          :class="['tabs_v_h_item', active === header.index ? 'tabs_v_h_i_active': '']"
          @click="tabSwitch(header.index)"
        >
          <el-badge :value="header.value !== 0 ? header.value : null" class="item">
            <span>{{ header.title }}</span>
          </el-badge>
        </div>
      </div>
      <div class="tabs_view_table_right">
        <pagination
          :total="total"
          :page.sync="queryParams.pageNum"
          :limit.sync="queryParams.pageSize"
          @pagination="getList"
        />
      </div>
    </div>
    <div class="tabs_view_slot_content">
      <slot name="content" />
    </div>
  </div>
</template>

<script>
export default {
  name: 'TabsView',
  props: {
    displayPag: {
      type: Boolean,
      default: true
    },
    params: {
      type: Object,
      default: {}
    },
    total: {
      type: [String, Number],
      default: 0
    },
    headerList: {
      type: Array,
      default: _ => []
    }
  },
  data() {
    return {
      active: 1,
      queryParams: {
        pageNum: 1,
        pageSize: 10
      }
    }
  },
  methods: {
    tabSwitch(index) {
      this.active = index;
      this.$emit('tab-switch', index);
    },
    getList() {
      this.$emit('get-list', Object.assign(this.queryParams, this.params));
    }
  }
}
</script>

<style lang="scss">
.tabs_view_table {
  margin-top: 20px;

  .tabs_view_header {

    .tabs_view_table_left {
      //float: left;
      display: inline-block;
      width: 50%;

      .tabs_v_h_item {
        display: inline-block;
        cursor: pointer;
        padding: 0 22px;
        height: 36px;
        line-height: 36px;
        font-size: 14px;
        background: #FFE3D8;
        border-radius: 16px 16px 0 0;
      }

      .tabs_v_h_item.tabs_v_h_i_active {
        font-weight: bold;
        font-size: 14px;
        color: #4174A5;
        background: #FFFFFF;
      }
    }

    .tabs_view_table_right {
      width: 50%;
      display: inline-block;
    }

  }

  .tabs_view_slot_content {
    padding: 30px;
    min-height: 650px;
    background-color: #FFFFFF;
  }
}
</style>
